NullReferenceException at Microsoft.Silverlight.Build.Tasks.CompileXaml.LoadAssemblies(ITaskItem[] R

Posted by Eugene Larchick on Stack Overflow See other posts from Stack Overflow or by Eugene Larchick
Published on 2010-05-12T11:41:55Z Indexed on 2010/05/12 11:44 UTC
Read the original article Hit count: 216

Filed under:
|
|

Hi, I updated my Visual Studio 2010 to the version 10.0.30319.1 RTM Rel and start getting the following exception during the build:

System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Silverlight.Build.Tasks.CompileXaml.LoadAssemblies(ITaskItem[] ReferenceAssemblies) at Microsoft.Silverlight.Build.Tasks.CompileXaml.get_GetXamlSchemaContext() at Microsoft.Silverlight.Build.Tasks.CompileXaml.GenerateCode(ITaskItem item, Boolean isApplication) at Microsoft.Silverlight.Build.Tasks.CompileXaml.Execute() at Bohr.Silverlight.BuildTasks.BohrCompileXaml.Execute()

The code of BohrCompileXaml.Execute is the following:

     public override bool Execute() {
        List<TaskItem> pages = new List<TaskItem>();
        foreach (ITaskItem item in SilverlightPages) {
            string newFileName = getGeneratedName(item.ItemSpec);
            String content = File.ReadAllText(item.ItemSpec);
            String parentClassName = getParentClassName(content);
            if (null != parentClassName) {
                content = content.Replace("<UserControl", "<" + parentClassName);
                content = content.Replace("</UserControl>", "</" + parentClassName + ">");
                content = content.Replace("bohr:ParentClass=\"" + parentClassName + "\"", "");
            }
            File.WriteAllText(newFileName, content);
            pages.Add(new TaskItem(newFileName));
        }

        if (null != SilverlightApplications) {
            foreach (ITaskItem item in SilverlightApplications) {
                Log.LogMessage(MessageImportance.High, "Application: " + item.ToString());
            }
        }

        foreach (ITaskItem item in pages) {
            Log.LogMessage(MessageImportance.High, "newPage: " + item.ToString());
        }


        CompileXaml xamlCompiler = new CompileXaml();
        xamlCompiler.AssemblyName = AssemblyName;
        xamlCompiler.Language = Language;
        xamlCompiler.LanguageSourceExtension = LanguageSourceExtension;
        xamlCompiler.OutputPath = OutputPath;
        xamlCompiler.ProjectPath = ProjectPath;
        xamlCompiler.RootNamespace = RootNamespace;
        xamlCompiler.SilverlightApplications = SilverlightApplications;
        xamlCompiler.SilverlightPages = pages.ToArray();
        xamlCompiler.TargetFrameworkDirectory = TargetFrameworkDirectory;
        xamlCompiler.TargetFrameworkSDKDirectory = TargetFrameworkSDKDirectory;
        xamlCompiler.BuildEngine = BuildEngine;
        bool result = xamlCompiler.Execute(); // HERE we got the error!  

And the definition of the task:

        <BohrCompileXaml 
           LanguageSourceExtension="$(DefaultLanguageSourceExtension)"
           Language="$(Language)" 
           SilverlightPages="@(Page)" 
           SilverlightApplications="@(ApplicationDefinition)" 
           ProjectPath="$(MSBuildProjectFullPath)"
           RootNamespace="$(RootNamespace)"
           AssemblyName="$(AssemblyName)" 
           OutputPath="$(IntermediateOutputPath)"
           TargetFrameworkDirectory="$(TargetFrameworkDirectory)" 
           TargetFrameworkSDKDirectory="$(TargetFrameworkSDKDirectory)"
           >

        <Output ItemName="Compile" TaskParameter="GeneratedCodeFiles" />

        <!-- Add to the list list of files written. It is used in Microsoft.Common.Targets to clean up 
             for a next clean build 
          -->
        <Output ItemName="FileWrites" TaskParameter="WrittenFiles" />
        <Output ItemName="_GeneratedCodeFiles" TaskParameter="GeneratedCodeFiles" />

    </BohrCompileXaml>

What can be the reason? And how can I get more info what's happening inside CompileXaml class?

© Stack Overflow or respective owner

Related posts about msbuild

Related posts about Silverlight